home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 January / january_2001.iso / intercd / root / ^4Developers / VB / visbasdb / VBDB / VBDB Code / VB6 Code / Class 5 / Example5-2AD.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-12-03  |  6.7 KB  |  193 lines

  1. VERSION 5.00
  2. Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
  3. Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
  4. Begin VB.Form frmBooks 
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "Books Database"
  7.    ClientHeight    =   3345
  8.    ClientLeft      =   45
  9.    ClientTop       =   330
  10.    ClientWidth     =   6165
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   3345
  15.    ScaleWidth      =   6165
  16.    StartUpPosition =   3  'Windows Default
  17.    Begin MSAdodcLib.Adodc datBooks 
  18.       Height          =   375
  19.       Left            =   3000
  20.       Top             =   2880
  21.       Width           =   3135
  22.       _ExtentX        =   5530
  23.       _ExtentY        =   661
  24.       ConnectMode     =   0
  25.       CursorLocation  =   3
  26.       IsolationLevel  =   -1
  27.       ConnectionTimeout=   15
  28.       CommandTimeout  =   30
  29.       CursorType      =   3
  30.       LockType        =   3
  31.       CommandType     =   8
  32.       CursorOptions   =   0
  33.       CacheSize       =   50
  34.       MaxRecords      =   0
  35.       BOFAction       =   0
  36.       EOFAction       =   0
  37.       ConnectStringType=   1
  38.       Appearance      =   1
  39.       BackColor       =   -2147483643
  40.       ForeColor       =   -2147483640
  41.       Orientation     =   0
  42.       Enabled         =   -1
  43.       Connect         =   "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\VBDB\Working\Biblio.mdb"
  44.       OLEDBString     =   "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\VBDB\Working\Biblio.mdb"
  45.       OLEDBFile       =   ""
  46.       DataSourceName  =   ""
  47.       OtherAttributes =   ""
  48.       UserName        =   ""
  49.       Password        =   ""
  50.       RecordSource    =   ""
  51.       Caption         =   "Books"
  52.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  53.          Name            =   "MS Sans Serif"
  54.          Size            =   8.25
  55.          Charset         =   0
  56.          Weight          =   400
  57.          Underline       =   0   'False
  58.          Italic          =   0   'False
  59.          Strikethrough   =   0   'False
  60.       EndProperty
  61.       _Version        =   393216
  62.    End
  63.    Begin MSDataGridLib.DataGrid grdBooks 
  64.       Bindings        =   "Example5-2AD.frx":0000
  65.       Height          =   2175
  66.       Left            =   120
  67.       TabIndex        =   2
  68.       Top             =   120
  69.       Width           =   5895
  70.       _ExtentX        =   10398
  71.       _ExtentY        =   3836
  72.       _Version        =   393216
  73.       HeadLines       =   1
  74.       RowHeight       =   15
  75.       BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  76.          Name            =   "MS Sans Serif"
  77.          Size            =   8.25
  78.          Charset         =   0
  79.          Weight          =   400
  80.          Underline       =   0   'False
  81.          Italic          =   0   'False
  82.          Strikethrough   =   0   'False
  83.       EndProperty
  84.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  85.          Name            =   "MS Sans Serif"
  86.          Size            =   8.25
  87.          Charset         =   0
  88.          Weight          =   400
  89.          Underline       =   0   'False
  90.          Italic          =   0   'False
  91.          Strikethrough   =   0   'False
  92.       EndProperty
  93.       ColumnCount     =   2
  94.       BeginProperty Column00 
  95.          DataField       =   ""
  96.          Caption         =   ""
  97.          BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
  98.             Type            =   0
  99.             Format          =   ""
  100.             HaveTrueFalseNull=   0
  101.             FirstDayOfWeek  =   0
  102.             FirstWeekOfYear =   0
  103.             LCID            =   1033
  104.             SubFormatType   =   0
  105.          EndProperty
  106.       EndProperty
  107.       BeginProperty Column01 
  108.          DataField       =   ""
  109.          Caption         =   ""
  110.          BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
  111.             Type            =   0
  112.             Format          =   ""
  113.             HaveTrueFalseNull=   0
  114.             FirstDayOfWeek  =   0
  115.             FirstWeekOfYear =   0
  116.             LCID            =   1033
  117.             SubFormatType   =   0
  118.          EndProperty
  119.       EndProperty
  120.       SplitCount      =   1
  121.       BeginProperty Split0 
  122.          BeginProperty Column00 
  123.          EndProperty
  124.          BeginProperty Column01 
  125.          EndProperty
  126.       EndProperty
  127.    End
  128.    Begin VB.CommandButton cmdAll 
  129.       Caption         =   "Show All Records"
  130.       Height          =   375
  131.       Left            =   120
  132.       TabIndex        =   1
  133.       Top             =   2880
  134.       Width           =   2775
  135.    End
  136.    Begin VB.CommandButton cmdLetter 
  137.       Caption         =   "A"
  138.       Height          =   375
  139.       Index           =   0
  140.       Left            =   120
  141.       TabIndex        =   0
  142.       Top             =   2400
  143.       Width           =   1455
  144.    End
  145. Attribute VB_Name = "frmBooks"
  146. Attribute VB_GlobalNameSpace = False
  147. Attribute VB_Creatable = False
  148. Attribute VB_PredeclaredId = True
  149. Attribute VB_Exposed = False
  150. Option Explicit
  151. Dim SQLAll As String
  152. Private Sub cmdAll_Click()
  153. 'Show all records
  154. datBooks.RecordSource = SQLAll + "ORDER BY Authors.Author"
  155. datBooks.Refresh
  156. End Sub
  157. Private Sub cmdLetter_Click(Index As Integer)
  158. If Index <> 25 Then
  159. 'Key other than Z clicked
  160. 'Append to SQLAll to limit records to letter clicked
  161.   datBooks.RecordSource = SQLAll + "AND Authors.Author > '" + cmdLetter(Index).Caption + " ' "
  162.   datBooks.RecordSource = datBooks.RecordSource + "AND Authors.Author < '" + cmdLetter(Index + 1).Caption + " ' "
  163. 'Z Clicked
  164. 'Append to SQLAll to limit records to Z Authors
  165.   datBooks.RecordSource = SQLAll + "AND Authors.Author > 'Z' "
  166. End If
  167. datBooks.RecordSource = datBooks.RecordSource + "ORDER BY Authors.Author"
  168. datBooks.Refresh
  169. End Sub
  170. Private Sub Form_Activate()
  171. 'Show all records initially
  172. Call cmdAll_Click
  173. End Sub
  174. Private Sub Form_Load()
  175. Dim I As Integer
  176. 'Size search buttons
  177. cmdLetter(0).Width = (frmBooks.ScaleWidth - 2 * cmdLetter(0).Left) / 26
  178. 'Create 25 new buttons
  179. 'Position new button next to prior button
  180. For I = 1 To 25
  181.   Load cmdLetter(I)
  182.   cmdLetter(I).Left = cmdLetter(I - 1).Left + cmdLetter(0).Width
  183.   cmdLetter(I).Caption = Chr(Asc("A") + I)
  184.   cmdLetter(I).Visible = True
  185. Next I
  186. 'Build basic SQL statement
  187. SQLAll = "SELECT Authors.Author,Titles.Title,Publishers.[Company Name] "
  188. SQLAll = SQLAll + "FROM Authors, Titles, Publishers, [Title Author] "
  189. SQLAll = SQLAll + "WHERE Titles.ISBN = [Title Author].ISBN "
  190. SQLAll = SQLAll + "AND Authors.Au_ID = [Title Author].Au_ID "
  191. SQLAll = SQLAll + "AND Titles.PubID = Publishers.PubID "
  192. End Sub
  193.